/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.mc.sdk.portalcenter.api;

import cn.hallele.infrastructure.metadata.io.Response;
import cn.hallele.mc.sdk.portalcenter.dto.OptionDTO;
import cn.hallele.mc.sdk.portalcenter.dto.TenantDTO;
import cn.hallele.mc.sdk.portalcenter.dto.TenantQueryDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * hallele_mc_sdk
 *
 * @author anle5
 * @since 2024/10/13 11:23
 */
@Tag(name = "租户中心")
public interface TenantApi {
    /**
     * 获取 租户列表
     *
     * @param condition 查询条件
     * @return List
     */
    @Operation(summary = "租户列表")
    @GetMapping("/tenant")
    Response<List<TenantDTO>> findAll(@Valid @ParameterObject @SpringQueryMap TenantQueryDTO condition);

    /**
     * 添加租户
     *
     * @param tenantDTO tenantDTO
     * @return List
     */
    @Operation(summary = "添加租户")
    @PostMapping("/tenant")
    Response<Void> addTenant(@Valid @RequestBody TenantDTO tenantDTO);

    /**
     * 修改租户
     *
     * @param tenantDTO tenantDTO
     * @return List
     */
    @Operation(summary = "修改租户")
    @PutMapping("/tenant")
    Response<Void> updateTenant(@Valid @RequestBody TenantDTO tenantDTO);

    /**
     * 获取租户下拉选项
     *
     * @return List
     */
    @Operation(summary = "获取租户下拉选项")
    @GetMapping("/options")
    Response<List<OptionDTO<TenantDTO, Integer>>> getOptions();

    /**
     * 获取租户详情
     *
     * @param id id
     * @return TenantDTO
     */
    @Operation(summary = "获取租户详情")
    @GetMapping("/tenant/{id}")
    Response<TenantDTO> getTenant(@NotNull @Range(max = Integer.MAX_VALUE) @PathVariable("id") Integer id);

    /**
     * 删除租户
     *
     * @param ids ids
     * @return TenantDTO
     */
    @Operation(summary = "删除租户")
    @DeleteMapping("/tenant/{ids}")
    Response<Void> deleteTenant(@NotEmpty @PathVariable("ids") List<Integer> ids);
}
